package com.happy_hao.topbiz.controller.base.msgController;

import com.happy_hao.topbiz.api.MsgApi;
import com.happy_hao.topbiz.common.Result;
import com.happy_hao.topbiz.dto.msgDto.EmailRequest;
import com.happy_hao.topbiz.dto.msgDto.NoPeriodStartRequest;
import com.happy_hao.topbiz.dto.msgDto.PeriodicSendRequest;
import com.happy_hao.topbiz.dto.msgDto.SystemInfoRequest;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/topbiz/msg/email")
public class EmailController {


    @Resource
    private MsgApi msgApi;

    @PostMapping("/instantSend")
    public Result instantSend(@Valid @RequestBody EmailRequest emailRequest) {
        return msgApi.instantSend(emailRequest);
    }

    @PutMapping("/newScheduledSend")
    public Result newScheduledSend(@Valid @RequestBody EmailRequest emailRequest) {
        return msgApi.newScheduledSend(emailRequest);
    }

    // 启动周期性发送
    @PostMapping("/periodicSend")
    public Result periodicSend(@RequestBody @Validated PeriodicSendRequest periodicSendRequest) {
        System.out.println("periodicSendRequest:"+periodicSendRequest);
        return msgApi.periodicSend(periodicSendRequest);
    }

    // 停止周期性发送
    @GetMapping("/stopPeriodicSend/{taskId}")
    public ResponseEntity<String> stopPeriodicSend(@PathVariable String taskId) {
        return msgApi.stopPeriodicSend(taskId);
    }

//非周期性发送
    @PostMapping("/noPeriodStart")
    public ResponseEntity<String> noPeriodStart(@RequestBody @Validated NoPeriodStartRequest noPeriodStartRequest) {
        return msgApi.noPeriodStart(noPeriodStartRequest);
    }
//取消非周期性发送
    @GetMapping("/noPeriodsTop/{taskId}")
    public ResponseEntity<String> noPeriodsTop(@PathVariable String taskId) {
        return msgApi.noPeriodsTop(taskId);
    }
//发送系统消息
    @PostMapping("/systemInfo")
    public Result systemInfo(@RequestBody  @Validated SystemInfoRequest systemInfoRequest) {
        return msgApi.systemInfo(systemInfoRequest);
    }

}
